<script>
import TreeCard from '@/components/TreeCard/index.vue'
import CardItems from '@/components/CardItems/index.vue'
import { cardConfig } from './config/cardConfig'
import { popConfig } from './config/popConfig'
import { selectConfig } from './config/selectConfig'
import { headerConfig } from './config/tableConfig'

export default {
  name: 'CarbonNeutralityPlan',
  components: { TreeCard, CardItems },
  data() {
    return {
      isExpand: true,
      expandLeft: 200,
      type: null,
      selectList: []
    }
  },
  methods: {
    // /**
    //  * 获取楼栋列表
    //  * @param sceneProjectId
    //  */
    // async loadingEdificeListByProjectId(sceneProjectId, selectList, selectData) {
    //   const res = await this.$api.commonSelected({
    //     code: 'SceneEdificeSelected',
    //     param: sceneProjectId
    //   })
    //   const configItem = selectList[1]
    //   configItem.optionList = res.data.map(item => {
    //     return {
    //       code: item.value,
    //       name: item.label
    //     }
    //   })
    //   this.$set(this.selectList, 1, {
    //     ...configItem
    //   })
    //   this.$refs.cardItemsRef.setSelectModuleValue({
    //     ...selectData
    //   })
    // },

    // /**
    //  * 获取楼层列表
    //  * @param sceneEdificeId
    //  */
    // async loadingFloorListByProjectId(sceneEdificeId, selectList, selectData) {
    //   const res = await this.$api.commonSelected({
    //     code: 'SceneFloorSelected',
    //     param: sceneEdificeId
    //   })
    //   const configItem = selectList[2]
    //   configItem.optionList = res.data.map(item => {
    //     return {
    //       code: item.value,
    //       name: item.label
    //     }
    //   })
    //   this.$set(this.selectList, 2, {
    //     ...configItem
    //   })
    //   this.$refs.cardItemsRef.setSelectModuleValue({
    //     ...selectData
    //   })
    // },
    selectChange(selectData, prop, selectList) {
      // this.selectList = JSON.parse(JSON.stringify(selectList))
      // if (prop === 'sceneProjectId') {
      //   this.loadingEdificeListByProjectId(selectData[prop], selectList, selectData)
      // } else if (prop === 'sceneEdificeId') {
      //   this.loadingFloorListByProjectId(selectData[prop], selectList, selectData)
      // }
    }
  },
  computed: {
    cardConfig() {
      return cardConfig['carbon-neutrality-plan'] || {}
    },
    popConfig() {
      return popConfig['carbon-neutrality-plan'] || {}
    },
    selectConfig() {
      return selectConfig['carbon-neutrality-plan'] || []
    },
    /**
     * 表头配置
     */
    headerConfig() {
      return headerConfig['carbon-neutrality-plan'] || []
    }
  }
}
</script>

<template>
  <div class="plan-box">
    <div class="CardItems-box">
      <CardItems
        ref="cardItemsRef"
        :card-config="cardConfig"
        :pop-config="popConfig"
        :select-config="selectConfig"
        :header-config="headerConfig"
        :dynamic-select-list="selectList"
        @selectChange="selectChange"
      />
    </div>
  </div>
</template>
<style lang="scss" scoped>
.plan-box {
  display: flex;
  width: 100%;
  height: 100%;

  .expand-box {
    position: absolute;
    top: 50%;
    height: 40px;
    line-height: 40px;
    width: 12px;
    text-align: center;
    margin-top: -20px;
    font-size: 12px;
    color: #909399;
    background-color: #ededed;
    border-radius: 0 4px 4px 0;
    transition: left 0.3s;
    cursor: pointer;
    z-index: 3;

    &:hover {
      background-color: #ddd;
    }

    .el-input__icon {
      font-style: normal;
      font-weight: 400;
      font-variant: normal;
      text-transform: none;
      line-height: 1;
      vertical-align: baseline;
      display: inline-block;
    }
  }

  .TreeCard-box {
    height: 100%;
    transition: all 0.3s;

    .tree-card {
      border: 1px solid #eee;
      background-color: #fff;
    }

    &.is-expand {
      overflow: hidden;
      margin-right: 0;
    }
  }

  .CardItems-box {
    flex: 1;
  }
}
</style>
